﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.Domain.Entities;
using Volo.Abp.Domain.Entities.Auditing;
using Volo.Abp.MultiTenancy;

namespace Himp.Platform
{
    /// <summary>
    /// 表格
    /// </summary>
    public class DataTableDict : FullAuditedAggregateRoot<Guid>, IMultiTenant
    {
        /// <summary>
        /// 表格编码
        /// </summary>
        public string DataTableCodg { get; set; }

        /// <summary>
        /// 表格名称
        /// </summary>
        public string DataTableName { get; set; }

        /// <summary>
        /// 模版
        /// </summary>
        public EnumTableTemplateType TableTemplateType { get; set; }

        /// <summary>
        /// 说明
        /// </summary>
        public string? Exp { get; set; }

        /// <summary>
        /// 
        /// </summary>
        public bool DefaultFlag { get; set; }

        /// <summary>
        /// 版本
        /// </summary>
        public int Ver { get; set; }

        /// <summary>
        /// Api地址
        /// </summary>
        public Guid? OpenApiDictId { get; set; }

        ///// <summary>
        ///// 
        ///// </summary>
        //public OpenApiConfig? OpenApiDict { get; set; }

        /// <summary>
        /// 
        /// </summary>
        public IList<DataTableColumn> DataTableColumns { get; set; }

        /// <summary>
        /// 
        /// </summary>
        public Guid ProductTopicId { get; set; }

        /// <summary>
        /// 
        /// </summary>
        public AppTopic ProductTopic { get; set; }

        /// <summary>
        /// 
        /// </summary>
        public Guid? TenantId { get; set; }

        /// <summary>
        /// 
        /// </summary>
        public DataTableDict()
        { 
            
        }

        public DataTableDict(string stdTableName, EnumTableTemplateType tableTemplateType, Guid topicDictId
            ,Guid? openApiDictId)
        {
            DataTableName = stdTableName;
            TableTemplateType= tableTemplateType;
            ProductTopicId = topicDictId;
            OpenApiDictId = openApiDictId;
        }

        public bool CanDelete()
        {
            return !DefaultFlag;
        }

        public void SetStdTableCodg(string codg)
        { 
            DataTableCodg = codg;
        }
    }
}
